from datetime import datetime
import boto3
import json

client = boto3.client('events')


def trigger_initiator():
    detail = {"state": "STARTED",
              "metadata": {
                  "SpiderName": "CoreProductsSpider",
                  "InitiatorName": "AllCoreProducts"
              },
              "payload": {
                  "tt": "CoreProductsMostWishedFor"
              }
              }
    putEventsResp = client.put_events(
        Entries=[
            {
                # "Time": datetime(2021, 8, 1),
                "Source": "pt.spider",
                # 'Resources': [
                #     'string',
                # ],
                "DetailType": "Spider State-change Notification",
                "Detail": json.dumps(detail),
                # 'EventBusName': 'string',
                # 'TraceHeader': 'string'
            },
        ]
    )
    print(putEventsResp)
    print("done")


if __name__ == "__main__":
    trigger_initiator()
    pass